package com.itheima.job;

import com.itheima.mapper.OrderMapper;
import com.itheima.mapper.OrderSettingMapper;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;

import java.util.Calendar;
import java.util.Date;

@Component
public class OrderSettingTimingClean extends AdaptableJobFactory {

    @Autowired
    private OrderSettingMapper orderSettingMapper;

    public void run(){
        //定义日历对象
        Calendar calender = Calendar.getInstance();
        //获取年月,月份获取到刚好是前一个月
        int month = calender.get(calender.MONTH);
        int year = calender.get(calender.YEAR);

        //拼接
        String startDate=year+"-"+month+"-1";
        String endDate=year+"-"+month+"-10";

        System.out.println("quartz 清理预约设置数据任务开始执行了[清理的时间区间如下]"+new Date());

        System.out.println(startDate);
        System.out.println(endDate);

        orderSettingMapper.deleteHistoryDateByMonth(startDate,endDate);
    }
}
